home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / AppleShare Client API SDK / Headers / afpDataStream.h < prev   
Encoding:
C/C++ Source or Header  |  1999-11-02  |  12.8 KB  |  360 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        afpDataStream.h
  3.  
  4.      Contains:    Public Header file for the low level AppleShare Client API (AFP Protocol)
  5.  
  6.      Version:    3.8.5
  7.  
  8. */
  9. #ifndef __AFPDATASTREAM__
  10. #define __AFPDATASTREAM__
  11.  
  12. #ifndef __CONDITIONALMACROS__
  13. #include <ConditionalMacros.h>
  14. #endif
  15.  
  16. #ifndef __MIXEDMODE__
  17. #include <MixedMode.h>
  18. #endif
  19.  
  20. #ifndef __DEVICES__
  21. #include <Devices.h>
  22. #endif
  23.  
  24. #ifndef __APPLETALK__
  25. #include <AppleTalk.h>
  26. #endif
  27.  
  28. #ifndef __OPENTRANSPORT__
  29. #include <OpenTransport.h>
  30. #endif
  31.  
  32. #ifndef __OPENTPTINTERNET__
  33. #include <OpenTptInternet.h>
  34. #endif
  35.  
  36. #ifndef __OPENTPTAPPLETALK__
  37. #include <OpenTptAppleTalk.h>
  38. #endif
  39.  
  40.  
  41.  
  42.  
  43. #if PRAGMA_ONCE
  44. #pragma once
  45. #endif
  46.  
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50.  
  51. #if PRAGMA_IMPORT
  52. #pragma import on
  53. #endif
  54.  
  55. #if PRAGMA_STRUCT_ALIGN
  56.     #pragma options align=mac68k
  57. #elif PRAGMA_STRUCT_PACKPUSH
  58.     #pragma pack(push, 2)
  59. #elif PRAGMA_STRUCT_PACK
  60.     #pragma pack(2)
  61. #endif
  62.  
  63.  
  64.  
  65. /*    -------------------------------------------------------------------------
  66.     csCodes
  67.     ------------------------------------------------------------------------- */
  68. /* for PBControl calls*/
  69. enum {
  70.     afpGetAttnRoutine            = 252,                            /*    Get the default AFP Attention routine*/
  71.     dsOpenSession                = 244,                            /*    Open an AFP session to the server*/
  72.     dsGetStatus                    = 243,                            /*    Send a GetSrvrInfo request to the server*/
  73.     dsSendRequest                = 240,                            /*    Send an AFP command to the server*/
  74.     dsCloseSession                = 237,                            /*    Close the specified session*/
  75.     dsCloseAll                    = 232,                            /*    Close all sessions*/
  76.     dsIOCTL                        = 231,                            /*    Make an IOCTL call to the session endpoint iff it is TCP/IP*/
  77.                                                                 /* these will be retired soon    */
  78.     AFPInsSessMemBlk            = 246,                            /* insert the SMB into the drviers Queue    */
  79.     AFPRemSessMemBlk            = 245                            /* remove the SMB from the drviers Queue    */
  80. };
  81.  
  82. /* for PBStatus calls*/
  83. enum {
  84.     afpGetFSID                    = 127,                            /*    returns the File System ID    */
  85.     afpSVolInfo                    = 124,                            /*     returns basic info about the server volume (address, servername, username...)*/
  86.     afpXGetVolInfo                = 121,                            /*    returns extended info about the volume (server time offset, volume grade...)*/
  87.     afpGetSMBSize                = 118,                            /*  returns the size of the session memory block required for a new session*/
  88.     dsGetXPortInfo                = 236                            /*    returns information about the transport used for the given session*/
  89. };
  90.  
  91. /*    -------------------------------------------------------------------------
  92.     Data Stream Parameter Block
  93.     ------------------------------------------------------------------------- */
  94. typedef CALLBACK_API( void , DSIOCompletionProcPtr )(void *pb);
  95. /*
  96.     WARNING: DSIOCompletionProcPtr uses register based parameters under classic 68k
  97.              and cannot be written in a high-level language without 
  98.              the help of mixed mode or assembly glue.
  99. */
  100. typedef REGISTER_UPP_TYPE(DSIOCompletionProcPtr)                 DSIOCompletionUPP;
  101.  
  102.  
  103. /* csCode = dsSendRequest*/
  104.  
  105. struct DSWritePB {
  106.     UInt32                             dsWriteDataOffset;            /* <- specifies the write offset in the data*/
  107.     UInt32                             dsWriteBufferSize;            /* <- size of the data to be written*/
  108.     Byte *                            dsWriteBuffer;                /* <- ptr to data to be written*/
  109. };
  110. typedef struct DSWritePB                DSWritePB;
  111. /* csCode = dsGetStatus*/
  112.  
  113. struct DSGetStatusPB {
  114.     OTAddress *                        dsGSSrvrAddress;            /* <- OT Address of server to GetStatus() from (you also need to fill in the reply buffer & size)*/
  115.     const char *                    dsGSEpString;                /* <- endpoint string for the connection (nil == default)        */
  116. };
  117. typedef struct DSGetStatusPB            DSGetStatusPB;
  118. /* NOTE: 
  119.     Make sure the reply buffer for the dsGetStatus call is at least 2048 bytes, 
  120.     it may be advisable to make it larger in the future.    
  121. */
  122. /* csCode = dsOpenSession*/
  123.  
  124. struct DSOpenPB {
  125.     AttnRoutineUPP                     dsOSAttnRoutine;            /* <- Custom attention routine (nil == default)*/
  126.     OTAddress *                        dsOSSrvrAddress;            /* <- OT Address of server to open a session to*/
  127.     Ptr                             dsOSSessionBlock;            /* <- ptr to the SMB; memory reserved for the session.*/
  128.     const char *                    dsOSEpString;                /* <- endpoint string for the connection (nil == default)        */
  129. };
  130. typedef struct DSOpenPB                    DSOpenPB;
  131.  
  132. enum {
  133.     SMBSize                        = 3072                            /* size of the session memory block (must be allocated in the System Heap)*/
  134. };
  135.  
  136. /*    NOTE:
  137.     you should use the afpGetSMBSize call instead of this constant.
  138. */
  139.  
  140.  
  141. struct DSParamBlock {
  142.     QElem *                            qLink;                        /* - standard header stuff*/
  143.     short                             qType;                        /* - standard header stuff*/
  144.     short                             ioTrap;                        /* - standard header stuff*/
  145.     Ptr                             ioCmdAddr;                    /* - standard header stuff*/
  146.     DSIOCompletionUPP                 ioCompletion;                /* <- completion rtn point*/
  147.     OSErr                             ioResult;                    /* -> result from Async call*/
  148.     long                             cmdResult;                    /* -> result from the Server for the AFP Cmd*/
  149.     short                             ioVRefNum;                    /* - standard header stuff */
  150.     short                             ioCRefNum;                    /* <- RefNum of the ".AFPTranslator"*/
  151.     short                             csCode;                        /* <- DS Command code*/
  152.     short                             dsTimeout;                    /* <- ASP - How long to wait before retrying request, TCP - resv for internal use*/
  153.     short                             dsReserved1;                /* -  resv for internal use*/
  154.     long                             dsRetry;                    /* <- ASP - How many times to retry the request, TCP - unused*/
  155.     UInt16                             dsReserved2;                /* -  resv for internal use*/
  156.     short                             dsSessRefNum;                /* <- AFP Session number*/
  157.     short                             dsReserved3;                /* -  resv for internal use*/
  158.     short                             dsCmdBufferSize;            /* <- size of the command buffer*/
  159.     UInt8 *                            dsCmdBuffer;                /* <- ptr to the command buffer*/
  160.     UInt32                             dsReplyBufferSize;            /* <- size of the reply buffer*/
  161.     UInt8 *                            dsReplyBuffer;                /* <- ptr to the reply buffer*/
  162.  
  163.     union {
  164.         DSOpenPB                         open;
  165.         DSWritePB                         write;
  166.         DSGetStatusPB                     status;
  167.     }                                 csParam;
  168. };
  169. typedef struct DSParamBlock                DSParamBlock;
  170. typedef DSParamBlock *                    DSParamBlockPtr;
  171.  
  172. /* NOTE:
  173.     The dsCmdBuffer for the csCode = dsOpenSession case Must contain an AFP Login command.
  174.     The dsCmdBuffer for the csCode = dsCloseSession case Must contain an AFP Logout command.
  175.     Consult Inside AppleTalk for the packet formats.
  176. */
  177.  
  178.  
  179. struct DSXPortInfo {
  180.     long                             dsXPortType;                /* Transport Type (kASPXport, kTCPXport)*/
  181.     short                             dsXPortSessRefNum;            /* Session ref number for ASP or TCP*/
  182.     union {
  183.         InetAddress                     ipAddr;
  184.         DDPAddress                         ddpAddr;
  185.     }                                 addr;
  186. };
  187. typedef struct DSXPortInfo                DSXPortInfo;
  188. typedef DSXPortInfo *                    DSXPortInfoPtr;
  189. /* definitions for     dsXPortType */
  190. enum {
  191.     kASPXport                    = 0x00,
  192.     kTCPXport                    = 0x01
  193. };
  194.  
  195. /* argument structure for the dsIOCTL call, put a pointer to the DSIOCTLArgs 
  196.    struct into the dsCmdBuffer field & fill out the dsCmdBufferSize with
  197.    sizeof(DSIOCTLArgs). put the session refnum of the session
  198.    you are interested in, into dsSessRefNum. The result of the IOCTL
  199.    call will be in the cmdResult field. if the session is not a TCP/IP
  200.    session you will recieve an error (ENOTSOCK)
  201. */
  202.  
  203. struct DSIOCTLArgs {
  204.     UInt32                             ioctlCmd;
  205.     void *                            ioctlData;
  206. };
  207. typedef struct DSIOCTLArgs                DSIOCTLArgs;
  208. typedef DSIOCTLArgs *                    DSIOCTLArgsPtr;
  209.  
  210.  
  211.  
  212.  
  213. struct GetVolSessInfoRec {
  214.     short                             sessAFPVersion;                /*    AFP version number: */
  215.     short                             sessReferenceNumber;        /*    AFP session reference number*/
  216.     short                             sessAFPVolID;                /*    AFP volume identifier*/
  217.     OTAddress *                        sessServerAddress;            /*    server internet address*/
  218.     short                             sessUAMType;                /*    user authentication method*/
  219.     StringPtr                         sessUserNamePtr;            /*    ptr to user name string*/
  220.     Ptr                             sessVolIconPtr;                /*    ptr to server volume icon/mask*/
  221.     StringPtr                         sessWhereStringPtr;            /*    ptr to "where" information string, shown in the Get Info window*/
  222. };
  223. typedef struct GetVolSessInfoRec        GetVolSessInfoRec;
  224. typedef GetVolSessInfoRec *                GetVolSessInfoRecPtr;
  225. enum {
  226.     kAFPVersion11                = 1,
  227.     kAFPVersion20                = 2,
  228.     kAFPVersion21                = 3,
  229.     kAFPVersion22                = 4,
  230.     kAFPVersion23                = 5
  231. };
  232.  
  233. enum {
  234.     kNoUserAuth                    = 1,                            /*    'No User Authent' UAM (Guest)*/
  235.     kCleartextAuth                = 2,                            /*    'Cleartxt Passwrd' UAM     (types 2 & 3 will be automatically upgraded to 6 if avail.)*/
  236.     kRandnumAuth                = 3,                            /*    'Randnum Exchange' UAM */
  237.     k2WayRandnumAuth            = 6,                            /*    '2-Way Randnum exchange'*/
  238.     kEncryptPassXport            = 7,                            /*  'DHXCAST128' UAM (Diffie Hellman password transport)*/
  239.     kMinCustomUAM                = 128                            /*    Minimum type value for a Custom UAM*/
  240. };
  241.  
  242.  
  243. struct GetVolSessInfoPB {
  244.     QElemPtr                         qLink;                        /*  -  standard header stuff*/
  245.     short                             qType;                        /*  -  standard header stuff*/
  246.     short                             ioTrap;                        /*  -  standard header stuff*/
  247.     Ptr                             ioCmdAddr;                    /*  -  standard header stuff*/
  248.     IOCompletionUPP                 ioCompletion;                /* <-  completion rtn pointer*/
  249.     OSErr                             ioResult;                    /*  -> result from Async call*/
  250.     StringPtr                         ioNamePtr;                    /*  -  standard header stuff*/
  251.     short                             ioVRefNum;                    /*  -  standard header stuff*/
  252.     short                             ioRefNum;                    /* <-  RefNum of the ".AFPTranslator"*/
  253.     short                             csCode;                        /* <-  allways afpSVolInfo*/
  254.     Ptr                             vcbPtr;                        /* <-  pointer to the VCB that you want info about*/
  255.     GetVolSessInfoRecPtr             sessInfoBuffer;                /* <-  pointer to the GetVolSessInfoRec to be filled*/
  256.     long                             sessInfoSize;                /* <-  size of the GetVolSessInfoRec*/
  257.     long                             actSessInfoSize;            /*  -> actual size of the data returned*/
  258. };
  259. typedef struct GetVolSessInfoPB            GetVolSessInfoPB;
  260. typedef GetVolSessInfoPB *                GetVolSessInfoPBPtr;
  261.  
  262. /* the AFPInsSessMemBlk & AFPRemSessMemBlk  calls are currently  required
  263.    when opening or closing a session. Make the AFPInsSessMemBlk call after the dsOpenSession
  264.    call succeeds (or returns afpAuthContinue), with the same dsOSSessionBlock that you
  265.    sent into dsOpenSession. You need to call AFPRemSessMemBlk with that same pointer after
  266.    calling dsCloseSession or dsCloseAll. 
  267. */
  268.  
  269. struct AFPInsRemSMBParam {
  270.     QElemPtr                         qLink;                        /*  -  standard header stuff    */
  271.     short                             qType;                        /*  -  standard header stuff    */
  272.     short                             ioTrap;                        /*  -  standard header stuff    */
  273.     Ptr                             ioCmdAddr;                    /*  -  standard header stuff    */
  274.     IOCompletionUPP                 ioCompletion;                /* <-  completion rtn pointer    */
  275.     OSErr                             ioResult;                    /*  -> result from Async call    */
  276.     StringPtr                         ioNamePtr;                    /*  -  standard header stuff    */
  277.     short                             ioVRefNum;                    /*  -  standard header stuff    */
  278.     short                             ioRefNum;                    /* <-  RefNum of the ".AFPTranslator"            */
  279.     short                             csCode;                        /* <-  AFPInsSessMemBlk or AFPRemSessMemBlk     */
  280.     Ptr                             smbPtr;                        /* <-> pointer to the SMB to insert or remove    */
  281. };
  282. typedef struct AFPInsRemSMBParam        AFPInsRemSMBParam;
  283.  
  284. typedef AFPInsRemSMBParam *                AFPInsRemSMBPBPtr;
  285. /* Server Info Buffer returned from the dsGetStatus call     */
  286. /* you should make your buffer at least 1024 bytes in size.    */
  287. /* a partial definition of the AFPSrvrInfo data structure (the fixed portion) */
  288.  
  289. struct AFPSrvrInfo {
  290.     short                             fMachineOffset;
  291.     short                             fVerCountOffset;
  292.     short                             fUAMCountOffset;
  293.     short                             fIconOffset;
  294.     short                             fFlags;
  295.     unsigned char                     fSrvrName[2];
  296. };
  297. typedef struct AFPSrvrInfo                AFPSrvrInfo;
  298.  
  299. /* definitions for the fFlags word    */
  300. enum {
  301.     srvSCopyFile                = 0,                            /* Server supports FPCopyFile call*/
  302.     srvSChangePswd                = 1,                            /* Server supports FPChangePassword call*/
  303.     srvNoPswdSave                = 2,                            /* Workstation should not save password*/
  304.     srvSServerMsgs                = 3,                            /* Server supports server messages*/
  305.     srvSSrvrSig                    = 4,                            /* Server supports Server Signatures  (AFP 2.2)*/
  306.     srvSupportsTCP                = 5,                            /* Server may be connected to via TCP/IP (AFP 2.2)*/
  307.     srvSNotification            = 6                                /* Server will send notifications (AFP 2.2)*/
  308. };
  309.  
  310.  
  311.  
  312.  
  313. #if TARGET_CPU_68K
  314.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  315.                                                                                             #pragma parameter __D0 NAFPCommandSync(__A0)
  316.                                                                                             #endif
  317. EXTERN_API( OSErr ) NAFPCommandSync(DSParamBlockPtr paramBlock)                                ONEWORDINLINE(0xA004);
  318.  
  319.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  320.                                                                                             #pragma parameter __D0 NAFPCommandAsync(__A0)
  321.                                                                                             #endif
  322. EXTERN_API( OSErr ) NAFPCommandAsync(DSParamBlockPtr paramBlock)                            ONEWORDINLINE(0xA404);
  323.  
  324.  
  325. /* use only for dsCloseAll    */
  326.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  327.                                                                                             #pragma parameter __D0 NAFPCommandImmediate(__A0)
  328.                                                                                             #endif
  329. EXTERN_API( OSErr ) NAFPCommandImmediate(DSParamBlockPtr paramBlock)                        ONEWORDINLINE(0xA204);
  330.  
  331. #else
  332. #define    NAFPCommandSync(dspb)    PBControlSync((ParmBlkPtr)(dspb)
  333. #define    NAFPCommandAsync(dspb)    PBControlAsync((ParmBlkPtr)(dspb)
  334. #define    NAFPCommandImmediate(dspb)    PBControlImmed((ParmBlkPtr)(dspb)
  335. #endif  /* TARGET_CPU_68K */
  336.  
  337.  
  338.  
  339.  
  340. #if PRAGMA_STRUCT_ALIGN
  341.     #pragma options align=reset
  342. #elif PRAGMA_STRUCT_PACKPUSH
  343.     #pragma pack(pop)
  344. #elif PRAGMA_STRUCT_PACK
  345.     #pragma pack()
  346. #endif
  347.  
  348. #ifdef PRAGMA_IMPORT_OFF
  349. #pragma import off
  350. #elif PRAGMA_IMPORT
  351. #pragma import reset
  352. #endif
  353.  
  354. #ifdef __cplusplus
  355. }
  356. #endif
  357.  
  358. #endif /* __AFPDATASTREAM__ */
  359.  
  360.